package cn.wolfcode.wms.qo;

import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.*;

@Getter
@Setter
public class OrderChartQueryObject extends QueryObject {
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date beginTime;
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date endTime;
    private Long supplierId=-1l;
    private Long brandId =-1l;
    private String groupBy="e.name";

    public static final Map<String,String> groupTypes =new LinkedHashMap<>();
    static {
        groupTypes.put("e.name","订单人员");
        groupTypes.put("p.name","货品名称");
        groupTypes.put("s.name","供应商");
        groupTypes.put("p.brand_name","品牌");
        groupTypes.put("DATE_FORMAT(bill.vdate,'%Y-%m')","发货日期(月)");
        groupTypes.put("DATE_FORMAT(bill.vdate,'%Y-%m-%d')","发货日期(日)");
    }
    public void setFinalTime(Date date){
        if (date==null){
            return;
        }
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        calendar.add(Calendar.DAY_OF_MONTH,1);
        calendar.add(Calendar.SECOND,-1);
        this.beginTime=calendar.getTime();
    }

}
